#include <stdio.h>

int max_val_index(double arr[], int size);

int main() {

    printf("%d", max_val_index((double[]) {3, 5, 111, 651, 8}, 5));
    return 0;
}

int max_val_index(double arr[], int size) {
    int max_index = 0;
    int max=arr[0];
    for (int i = 0; i < size; ++i) {
        if (max < arr[i]) {
            max = arr[i];
            max_index = i;
        }
    }
    return max_index;
}